#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	long long n,l,r;
	cin>>n>>l>>r;
	if((l/n+1)*n-1>r) cout<<r%n;
	else  cout<<((l/n+1)*n-1)%n;
	return 0;
}
